home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / archivers / xfd / developer / sources / asm / 4getit!.a next >
Text File  |  1999-06-14  |  4KB  |  184 lines

  1. ***************************************************************
  2. **   XFD external decruncher for recognising the Imploder    **
  3. **    Hack as used on the PC Task executables.             **
  4. ***************************************************************
  5.  
  6.         SECTION    ForgetIt,CODE
  7.  
  8.         INCLUDE    AINCLUDE:IncDirs.i
  9.         INCLUDE    "libraries/xfdmaster.i"
  10.         INCLUDE    lvo.i
  11.  
  12. ; xfdForeman structure MUST be first thing in all external decrunchers
  13.  
  14. F_ForgetIt    moveq    #-1,d0            ;security
  15.         rts
  16.  
  17.         dc.l    XFDF_ID            ;id
  18.         dc.w    1            ;version
  19.         dc.w    0
  20.         dc.l    0,0            ;private
  21.         dc.l    S_ForgetIt        ;first slave
  22.  
  23. **************************************************
  24.  
  25. ; xfdSlave structure: this one doesn't support segment decrunching
  26.  
  27. S_ForgetIt    dc.l    0            ;no more slaves
  28.         dc.w    1            ;version
  29.         dc.w    33            ;master version
  30.         dc.l    N_ForgetIt        ;name
  31.         dc.w    XFDPFF_RELOC        ;flags
  32.         dc.w    0
  33.         dc.l    RB_ForgetIt        ;recog buffer
  34.         dc.l    DB_ForgetIt        ;decrunch buffer
  35.         dc.l    0            ;recog segment
  36.         dc.l    0            ;decrunch segment
  37.  
  38. N_ForgetIt    dc.b    '4Get It! Encryptor',0
  39.         even
  40.  
  41. ;-------------------------------------------------
  42.  
  43. ; Recog buffer function: receives buffer + length in a0/d0
  44.  
  45. RB_ForgetIt    Moveq.l    #1,d0            ; True
  46.         Cmp.l    #$3f3,(a0)+        ; Is this an executable?
  47.         Bne.b    .No
  48.         TST.L    4(A0)
  49.         BNE.B    .No
  50.  
  51.         Move.l    4(a0),d1
  52.         Add.l    d1,d1
  53.         Add.l    d1,d1            ; x4
  54.         Add.l    d1,a0
  55.         Lea    4*4(a0),a0        ; Skip the first/last hunk numbers,
  56.                         ; and 
  57.  
  58.         Cmp.l    #$3e9,(a0)
  59.         bne.b    .No
  60.  
  61.         Cmp.l    #$48e7c0e0,8(a0)    ; 
  62.         Bne.b    .No
  63.  
  64.         Cmp.l    #$41fa002a,12(a0)    ; 
  65.         Bne.b    .No
  66.  
  67.         Cmp.l    #$2018d098,16(a0)    ; 
  68.         Bne.b    .No
  69.  
  70.         Cmp.l    #"4GET",56(a0)
  71.         Bne.b    .No
  72.  
  73.         Cmp.l    #" IT!",60(a0)
  74.         Beq.b    .Yes
  75.  
  76. .No        Moveq.l    #0,d0
  77. .Yes        rts
  78.  
  79. ;-------------------------------------------------
  80.  
  81. ;Decrunch buffer function: receives bufferinfo in a0
  82.  
  83. DB_ForgetIt    MOVEM.L    d2-d7/a2-a6,-(A7)
  84.         move.l    a0,a5
  85.  
  86.         Move.l    xfdbi_SourceBufLen(a5),d0
  87.         move.l    d0,xfdbi_TargetBufSaveLen(a5)
  88.         move.l    d0,xfdbi_TargetBufLen(a5)
  89.  
  90.         move.l    xfdbi_TargetBufMemType(a5),d1
  91.         move.l    4.w,a6
  92.         JSR    _LVOAllocMem(A6)
  93.         moveq    #XFDERR_NOMEMORY,d1
  94.         Move.w    d1,xfdbi_Error(a5)
  95.         move.l    d0,xfdbi_TargetBuffer(a5)
  96.         beq    .NoMem
  97.  
  98.         Clr.w    xfdbi_Error(a5)
  99.  
  100.         Move.l    d0,a1
  101.         Move.l    xfdbi_SourceBuffer(a5),a0
  102.         Move.l    xfdbi_SourceBufLen(a5),d0
  103.         JSR    _LVOCopyMem(A6)
  104.  
  105. ;*-------------------------------------------------------------------------
  106. ;Read the size of encrypted data.
  107. ;*-------------------------------------------------------------------------
  108.  
  109.         move.l    xfdbi_TargetBuffer(a5),a0
  110.  
  111. .SeekSize    Cmp.w    #$223c,(a0)+
  112.         Bne.b    .SeekSize
  113.  
  114.         move.l    (a0)+,D1
  115.  
  116.  
  117. ;*-------------------------------------------------------------------------
  118. ;Find the encrypted data
  119. ;*-------------------------------------------------------------------------
  120.  
  121. .SeekData    Cmp.w    #' I',(a0)+
  122.         Bne.b    .SeekData
  123.         Cmp.w    #'T!',(a0)+
  124.         Bne.b    .SeekData
  125.  
  126. ;*-------------------------------------------------------------------------
  127. ; This is the loop where the decryption is done.
  128. ;*-------------------------------------------------------------------------
  129.  
  130.         MOVEM.L    a0/d1,-(A7)        ; a0-ptr to coded data
  131.                         ; d1-coded data size
  132.  
  133.         Subq.l    #1,d1            ; Correct for Dbra
  134.  
  135.         move.l    #$54909975,D0        ; "4GET" + " IT!" (Encryption val)
  136.  
  137. .Decode        Eor.l    D0,(A0)+
  138.         dbra    d1,.Decode
  139.  
  140.         MOVEM.L    (A7)+,a0/d1
  141.  
  142. ;*-------------------------------------------------------------------------
  143. ; Move the rest of the file 14 longwords towards the beginning of the file.
  144. ;*-------------------------------------------------------------------------
  145.  
  146.         Sub.l    #14*4,xfdbi_TargetBufSaveLen(a5)    ; Decryptor size
  147.  
  148.         Move.l    xfdbi_TargetBufSaveLen(a5),d0
  149.  
  150.         move.l    xfdbi_TargetBuffer(a5),a1
  151. .SeekStartCodeHunk
  152.         Subq.l    #4,d0            ; decrease copysize
  153.         Cmp.l    #$3e9,(a1)+
  154.         Bne.b    .SeekStartCodeHunk
  155.  
  156.         Addq.l    #4,a1
  157.         Subq.l    #4,d0
  158.  
  159.         JSR    _LVOCopyMem(A6)
  160.  
  161.  
  162. ;*-------------------------------------------------------------------------
  163. ; Fix up the hunk sizes
  164. ;*-------------------------------------------------------------------------
  165.         move.l    xfdbi_TargetBuffer(a5),a1
  166.         Sub.l    #14,20(a1)
  167.  
  168.         Move.l    8(a1),d0
  169.         Addq.l    #6,d0
  170.         Add.l    d0,d0
  171.         Add.l    d0,d0    ; x4
  172.         Add.l    d0,a1
  173.         Sub.l    #14,(a1)
  174.  
  175. ;*-------------------------------------------------------------------------
  176.  
  177.         Moveq.l    #1,d0        ; True = Decrunched ok
  178. .NoMem        MOVEM.L    (A7)+,d2-d7/a2-a6
  179.         Rts
  180.  
  181. **************************************************
  182.  
  183.         END
  184.